﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FazaDemo.BL.InterfaceDomain;
using FazaDemo.BL.SubDomains;

namespace FazaDemo.BL.Factories
{
    public class NavCondElemFactory : INavCondElemFactory
    {

        private const string ShowQuery = "ShowQuery";

        private const string OrderText = "Order";

        private const string Sprav = "Sprav";

        private const string NoEcq = "NoECQ";

        private const string ShowView = "ShowView";

        private const string FontBold = "FontBold";

        public NavCondElement GetNavCondElement(IList<string> fieldParams)
        {
            bool isShowQuery = fieldParams[4] == ShowQuery;
            bool isShowView = fieldParams[5] == ShowView;
            var orderCheck = fieldParams[7] == OrderText ? Order.Upper : Order.Not;
            bool haveSuppInfo = fieldParams[8] == Sprav;
            string infoIdField = fieldParams[9];
            int suppInfoId = infoIdField != NoEcq ? Convert.ToInt32(infoIdField) : 0;
            bool isFontBold = false;
            if (fieldParams.Count > 12)
                isFontBold = fieldParams[12] == FontBold;
            return new NavCondElement
            {
                ElemText = fieldParams[1],
                FieldDropType = Convert.ToChar(fieldParams[2]), 
                IsShowQuery = isShowQuery, 
                OrderCheck = orderCheck, 
                HaveSuppInfo = haveSuppInfo,
                SuppInfoId = suppInfoId,
                IsShowView = isShowView, 
                IsFontBold = isFontBold
            };
        }

    }
}
